package com.byit.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.byit.domain.AppCertificate;
import com.byit.mapper.AppCertificateMapper;
import com.byit.service.IAppCertificateService;
import com.byit.utils.PageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ClassName IAppCertificateServiceImpl
 * @Description TODO
 * @Author lxp
 * @Date 2019-01-07 11:41
 **/
@Service
public class AppCertificateServiceImpl extends ServiceImpl<AppCertificateMapper, AppCertificate> implements IAppCertificateService {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private AppCertificateMapper appCertificateMapper;


    @Override
    public void delAppCertificateById(Map<String, Object> params) {
        appCertificateMapper.delAppCertificateById(params);
    }

    @Override
    public Page<JSONObject> selectAppCertificateAll(Page<AppCertificate> pageInfo, Map<String, Object> params) {
        List<JSONObject> list = appCertificateMapper.selectAppCertificateAll(pageInfo, params);


        Page<JSONObject> page = PageUtil.transform(pageInfo);

        page.setRecords(list);

        return page;
    }

    @Override
    public List<JSONObject> selectListUserCertificates(Map<String, Object> params) {
        List<JSONObject> list = appCertificateMapper.selectListUserCertificates(params);

//        list.forEach(info -> {
//            //两张图片 如身份证 正反面
//            if (info.getString("picture").contains(",")) {
//
//            }
//        });

        return list;

    }

    @Override
    public List<JSONObject> selectUserCertificateByType(Map<String, Object> params) {

        List<JSONObject> list = appCertificateMapper.selectListUserCertificates(params);


        return list;
    }
}
